package office.action.business;

import java.util.List;

import office.action.business.form.BidBookConditionForm;
import office.action.business.form.TenderCompanyConditionForm;
import office.action.business.form.TenderCompanyForm;
import office.action.business.wrapper.BidBookWrapper;
import office.action.business.wrapper.TenderCompanyWrapper;
import office.service.business.IBidBookService;
import office.service.business.ITenderCompanyService;
import platform.common.action.BaseAction;
import platform.common.bo.Page;

/**
 * 
 * 竞标公司
 * 
 * @author ZhangYQ
 * 
 */
public class TenderCompanyAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private ITenderCompanyService tenderCompanyService;
	private IBidBookService bidBookService;
	private Page page; // 分页信息
	private List<TenderCompanyWrapper> wrapperList;
	private List<BidBookWrapper> bidBookWrapperList;
	private TenderCompanyForm form;
	private TenderCompanyConditionForm condition;
	private BidBookConditionForm bidBookCondition;
	private String id;

	/**
	 * 获取所有的竞标公司以及根据条件进行查询
	 * 
	 * @return
	 * @throws Exception
	 */
	public String findAllTenderCompany() throws Exception {
		page = tenderCompanyService.getPageInfo(condition);
		wrapperList = tenderCompanyService.findAllTenderCompany(condition,page);
		if(condition!=null){
			return "listTenderCompanyByPage";
		}
		return "findAllTenderCompany";
	}

	/**
	 * 初始化编辑竞标公司页面
	 * @return
	 * @throws Exception
	 */
	public String gotoEditTenderCompany() throws Exception {
		if(null!=id&&!"".equals(id)){
			form = tenderCompanyService.getById(id);
		}
		bidBookWrapperList=bidBookService.findAllBidBookByStatus(bidBookCondition);
		return "gotoEditTenderCompany";
	}

	/**
	 * 编辑竞标公司
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editTenderCompany() throws Exception {
		try {
			tenderCompanyService.editTenderCompany(form);
			if (null == form.getId()
					|| ("").equals(form.getId())) {
				this.getAjaxMessagesJson().setMessage(true, "", "新建成功");
			} else {
				this.getAjaxMessagesJson().setMessage(true, "", "编辑成功");
			}

		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}

	/**
	 * 
	 * <br/>
	 * 方法描述:分页条件查询产品结构
	 * 
	 * @return
	 * @throws Exception
	 */
	public String listTenderCompanyByPage() throws Exception {
		try {
			wrapperList = tenderCompanyService.findAllTenderCompany(condition, page);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw e;
		}
		return "listTenderCompanyByPage";
	}

	/**
	 * 初始化产品结构列表操作菜单
	 * 
	 * @return
	 * @throws Exception
	 */

	public String gotoTenderCompanyMenu() throws Exception {
		return "gotoTenderCompanyMenu";
	}

	/**
	 * 跳转到竞标公司删除确认页面
	 */
	public String gotoDeleteTenderCompany(){
		return "gotoDeleteTenderCompany";
	}
	
	/**
	 * 删除竞标公司
	 * @return
	 * @throws Exception
	 */
	public String delTenderCompany() throws Exception {
		try {
			tenderCompanyService.delTenderCompanyById(id);
			this.getAjaxMessagesJson().setMessage(true, "", "操作成功");
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw e;
		}
		return RESULT_AJAXJSON;
	}
	/**
	 * 
	 * <br/>
	 * 方法描述:根据标书获取表苏对应的竞标公司
	 * 
	 * @return
	 * @throws Exception
	 */
	public String listTenderCompanyByBidBookId() throws Exception {
		try {
			wrapperList = tenderCompanyService.findAllTenderCompanyByBidBookId(condition);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw e;
		}
		return "listTenderCompanyByBidBookId";
	}
	
	public ITenderCompanyService getTenderCompanyService() {
		return tenderCompanyService;
	}

	public void setTenderCompanyService(ITenderCompanyService tenderCompanyService) {
		this.tenderCompanyService = tenderCompanyService;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public List<TenderCompanyWrapper> getWrapperList() {
		return wrapperList;
	}

	public void setWrapperList(List<TenderCompanyWrapper> wrapperList) {
		this.wrapperList = wrapperList;
	}

	public TenderCompanyForm getForm() {
		return form;
	}

	public void setForm(TenderCompanyForm form) {
		this.form = form;
	}

	public TenderCompanyConditionForm getCondition() {
		return condition;
	}

	public void setCondition(TenderCompanyConditionForm condition) {
		this.condition = condition;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public IBidBookService getBidBookService() {
		return bidBookService;
	}

	public void setBidBookService(IBidBookService bidBookService) {
		this.bidBookService = bidBookService;
	}

	public BidBookConditionForm getBidBookCondition() {
		return bidBookCondition;
	}

	public void setBidBookCondition(BidBookConditionForm bidBookCondition) {
		this.bidBookCondition = bidBookCondition;
	}

	public List<BidBookWrapper> getBidBookWrapperList() {
		return bidBookWrapperList;
	}

	public void setBidBookWrapperList(List<BidBookWrapper> bidBookWrapperList) {
		this.bidBookWrapperList = bidBookWrapperList;
	}
	
	
}
